#include <stdio.h>

#define N 100

int n,a[N][N],dp[N][N];


int main(int argc, char const *argv[])
{
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		for(int j=0;j<=i;++j)
		{
			scanf("%d",&a[i][j]);
		}
	}
	dp[0][0] = a[0][0];
	for(int i=1;i<n;++i)
	{
		dp[i][0] = dp[i-1][0] + a[i][0];
		dp[i][i] = dp[i-1][i-1] + a[i][i];
		for(int j=1;j<i-1;++j)
		{
			dp[i][j] = dp[i-1][j-1] > dp[i-1][j]?dp[i-1][j-1]:dp[i-1][j];
			dp[i][j] += a[i][j];
		}
	}
	int max = -1;
	for(int i=0;i<n;++i)
	{
		max = dp[n-1][i] > max?dp[n-1][i]:max;
	}
	printf("%d\n",max);
	return 0;
}